#include <iostream>
#include <iomanip>
#include "EquationSolver.h"

using namespace std;

double f(double h){
    return 10 * (0.5*M_PI - asin(h) - h*sqrt(1 - h*h)) - 12.4;
}

double df(double h){
    return -20 * sqrt(1 - h*h);
}

int main()
{
    typedef double (*fp)(double);
    fp fpi = f;
    fp dfpi = df;
    MyFunc f(fpi,dfpi);
    cout << "Question E: " << endl;
    double err = std::numeric_limits<double>::epsilon();

    Bisection B(0,1,err,err,100,f);
    Newton N(0.5,err,100,f);
    Secant S(0.5,0.3,err,err,100,f);

    cout << "The bisection result is " << setiosflags(ios::fixed) << setprecision(2) << B.solve() << endl;
    cout << "The Newton result is " << setiosflags(ios::fixed) << setprecision(2) << N.solve() << endl;
    cout << "The secant result is " << setiosflags(ios::fixed) << setprecision(2) << S.solve() << endl;
    cout << endl;

    return 0;
}